<%--
    Document   : LibraryBook
    Created on : 14.02.2010, 12:34:31
    Author     : Morfant
--%>


<%@page import="java.math.BigInteger"%>
<%@page import="stud.cp.user.plugins.designer.DishesPluginBeanLocal"%>
<%@page import="stud.cp.user.valueobjects.Parameter"%>
<%@page import="stud.cp.user.valueobjects.PropertyListValue"%>
<%@page import="stud.cp.user.valueobjects.DBObject"%>
<%@page import="stud.cp.user.valueobjects.UserType"%>
<%@page import="stud.cp.user.valueobjects.PropertyTypeDef"%>
<%@page import="stud.cp.core.plugins.Plugin"%>
<%@page import="stud.cp.user.valueobjects.DBObjectType"%>
<%@page import="java.beans.DesignMode"%>
<%@page import="stud.cp.user.valueobjects.PropertyGroup"%>
<%@page import="stud.cp.user.valueobjects.PropertyType"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <%@include file="/header.jsp" %>
    <body>
        <div class="page">
            <%@include file="/cap.jsp" %>
            <div id="main">
                <h2>Просмотр состояния склада</h2>
                <fieldset>
                    <legend>Данные</legend>

                    <p>
                        <span class="highlight-delete-item">
                            <label for="">
                                Состояние склада
                            </label>
                        </span>

                    <div class="TopHeaderOfTree">
                        <div>Продукты: </div>
                        <ul class="Container">
                            <%List<DBObjectType> listOfProductsTypes =
                                        (List<DBObjectType>) request.getAttribute(DishesPluginBeanLocal.PRODUCT_OBJECT_TYPE_LIST);
                                List<DBObject> listOfProducts;
                                int i, j, numberOfProductTypes, numberOfProducts;
                                i = 0;
                                numberOfProductTypes = listOfProductsTypes.size();
                                DBObjectType productType;
                                DBObject product;
                                List<Parameter> productParameterList;
                                Parameter costParameter = null, storeTypeParameter = null, amountParameter = null;

                                while (i < numberOfProductTypes) {
                                    productType = listOfProductsTypes.get(i);
                                    i++;%>            
                            <li class="Node IsRoot ExpandLeaf <%=((i == numberOfProductTypes) ? "IsLast" : "")%> ">
                                <div class="Expand"></div>
                                <div class="RootContent"><%=productType.getName()%></div>
                                <ul class="Container">
                                    <%
                                        listOfProducts = (List<DBObject>) request.getAttribute(productType.getObject_type_id().toString());
                                        j = 0;
                                        numberOfProducts = listOfProducts.size();
                                        if (numberOfProducts > 0) {
                                            while (j < numberOfProducts) {
                                                product = listOfProducts.get(j);
                                                j++;
                                                productParameterList =
                                                        (List<Parameter>) request.getAttribute(
                                                        DishesPluginBeanLocal.PRODUCT_PARAMETER_LIST_FOR_PRODUCT + "=" + product.getObject_id().toString());
                                                for (Parameter param : productParameterList) {
                                                    if (param.getProperty_id().equals(PluginConst.COST_PROPERTY_ID)) {
                                                        costParameter = param;
                                                    }
                                                    if (param.getProperty_id().equals(PluginConst.STORE_TYPE_PROPERTY_ID)) {
                                                        storeTypeParameter = param;
                                                        amountParameter = param;
                                                    }
                                                }

                                    %>

                                    <li class="Node ExpandLeaf <%=((j == numberOfProducts) ? "IsLast" : "")%>">
                                        <div class="Expand"></div>
                                        <!-- Имя продуктаю -->
                                        <div name="Content" class="Content">
                                            <%=(product.getName())%>
                                            <div>

                                            </div><ul class="Container">
                                                <li class="Node ExpandLeaf IsLast">
                                                    <div class="Expand"></div>
                                                    <div class="Content">
                                                        <%=amountParameter.getValue()%>
                                                        <%=storeTypeParameter.getProperty_list_value_id().equals(new BigInteger("3"))
                                                                ? " кг. "
                                                                : " шт. "%>
                                                    </div>
                                                </li></ul>
                                        </div>

                                    </li>

                                <%}
                                        } else {%>
                                        <li class="Node ExpandLeaf IsLast">
                                            <div class="Expand"></div>
                                            <div class="Content">Продукты данного типа отсутствуют!</div>
                                        </li>
                                        <%}%>
                                    </ul>
                                </li>    
                                <%}%>
                            </ul>
                    </div>        

                    </p>



                </fieldset>

                <div id="objectmenucontainer">
                    <ul id="objectmenu">
                        <li><a href="<%=response.encodeURL("warehouse-action.do")
                                + "?"
                                + PluginConst.SUBACTION
                                + "="
                                + PluginConst.GET_LIST%>">Вернуться к списку приходов</a></li>
                    </ul>
                </div>
                <div id="footer">
                </div>
            </div>
        </div>
    </body>
</html>
